<template>
  <section>
    <el-row>营销记录列表</el-row>
    <el-table :data="list">
      <el-table-column type="index" label="序号"/>
      <el-table-column label="model">
        <template slot-scope="scope">
          {{modelTypeList.find(type=>type.val === scope.row.modelType).name}}
          <!--computeTypeList-->
        </template>
      </el-table-column>
      <el-table-column label="统计类型">
        <template slot-scope="scope">
          {{computeTypeList.find(type=>type.val === scope.row.type).name}}
        </template>
      </el-table-column>
      <el-table-column label="内容类型">
        <template slot-scope="scope">
          {{typeList.find(type=>type.val === scope.row.contentType).name}}
        </template>
      </el-table-column>
      <el-table-column label="内容详情">
        
      </el-table-column>
    </el-table>
    <el-pagination v-show="totalPage>0" style="margin-top:20px;" small
                   layout="prev, pager, next"
                   :page-count="totalPage"
                   @current-change="goPage">
    </el-pagination>
  </section>
</template>

<script>
  import {mapGetters, mapActions, mapMutations} from 'vuex'
  import Vue from 'vue'//后续添加属性，需要vue联动
  import errHandler from '@/assets/errHandler'
  export default {
    name: "recordList",
    data(){
      return{
        list:null,
        totalPage:0,
        modelTypeList:[
          {name:'分享',code:'share',val:1},
          {name:'广告',code:'ad',val:2}
        ],
        typeList:[
          {name:'活动',code:'activity',val:1},
          {name:'商品',code:'goods',val:2}
        ],
        computeTypeList:[
          {name:'系统',code:'system',val:1},
          {name:'营销',code:'marketing',val:2},
          {name:'用户',code:'member',val:3},
        ],
      }
    },
    watch:{
    },
    created(){
      this.getList()
      this.getGiftList()
    },
    methods: {
      ...mapActions({
        fetch: 'fetch'
      }),
      goPage(val){
        this.getList(val-1)
      },
      getList(pageNo){
        this.fetch({name:"getMarketingRecordList",data:{page:pageNo?pageNo:0}})
          .then(res=>{
            console.log('list----',res)
            this.list=res.content
            this.totalPage=res.totalPages
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      },
      getGiftList(pageNo){
        this.fetch({name:"getGiftList",data:{page:pageNo?pageNo:0}})
          .then(res=>{
            console.log('getGiftList----',res)
          })
          .catch(err=>{
            console.log(err)
            errHandler.handle(this,err)
          })
      }
    }
  }
</script>

<style scoped>

</style>
